package org.yudidi.properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by didi on 24/06/2018.
 */
@Component
//@PropertySource({"classpath:application-dev.properties"})//配置文件位于默认路径,可以不用这行
public class PropertiesByValue {
    private static final Logger logger = LoggerFactory.getLogger(PropertiesByValue.class);

    @Value("${dev.value.name}")
    private String name;

    @Value("${dev.value.age}")
    private Integer age;

    @PostConstruct
    public void valueInjectTest() {
        logger.error("使用 @Value 和 profile 文件的结合实现属性值的注入：name = {}, age = {}", name, age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
